package com.springapp.mvc;

import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

@Controller
public class HelloController {
	@RequestMapping(value = {"/{name}"}, method = RequestMethod.GET)
	public String printWelcomeWithName(@PathVariable("name") String name, ModelMap model) {
		model.addAttribute("message", ", " + name);
		return "hello";
	}
    @RequestMapping(value = {"/"}, method = RequestMethod.GET)
    public String printDefaultWelcome(ModelMap model) {
        model.addAttribute("message", "");
        return "hello";
    }
}